using ASP;
using HoWave.Alipay;
using HoWave.Common;
using HoWave.Web;
using HoWave.Web.Shop.Member;
using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Web;
using System.Web.Profile;
using System.Web.SessionState;
using System.Web.UI.HtmlControls;
public class return_url_OrderPay : Member, IRequiresSessionState
{
	protected HtmlForm form1;
	private Shop_Order _order = null;
	protected DefaultProfile Profile
	{
		get
		{
			return (DefaultProfile)this.Context.Profile;
		}
	}
	protected global_asax ApplicationInstance
	{
		get
		{
			return (global_asax)this.Context.ApplicationInstance;
		}
	}
	protected Shop_Order m_order
	{
		get
		{
			Shop_Order order;
			if (this._order == null)
			{
				this._order = new Shop_Order(this.conn);
				order = this._order;
			}
			else
			{
				order = this._order;
			}
			return order;
		}
	}
	protected void Page_Load(object sender, EventArgs e)
	{
		SortedDictionary<string, string> requestGet = this.GetRequestGet();
		if (requestGet.Count > 0)
		{
			Notify notify = new Notify();
			bool flag = notify.Verify(requestGet, base.Request.QueryString["notify_id"], base.Request.QueryString["sign"]);
			if (flag)
			{
				string text = base.Request.QueryString["trade_no"];
				string paymentNum = base.Request.QueryString["out_trade_no"];
				string text2 = base.Request.QueryString["total_fee"];
				string text3 = base.Request.QueryString["subject"];
				string text4 = base.Request.QueryString["body"];
				string text5 = base.Request.QueryString["buyer_email"];
				string text6 = base.Request.QueryString["trade_status"];
				Conn conn = new Conn();
				OrderAction orderAction = new OrderAction(conn);
				if (base.Request.QueryString["trade_status"] == "TRADE_FINISHED" || base.Request.QueryString["trade_status"] == "TRADE_SUCCESS")
				{
					orderAction.PayReturn(paymentNum, "NotPaySaler");
					HttpContext.Current.Response.Redirect(this.config["SiteUrl"].ToString().Trim() + "Member/Shop_BuyManageOrder.aspx");
				}
				else
				{
					base.Response.Write("trade_status=" + base.Request.QueryString["trade_status"] + "支付失败！");
				}
			}
			else
			{
				base.Response.Write("验证失败！");
			}
		}
		else
		{
			base.Response.Write("无返回参数");
		}
	}
	public SortedDictionary<string, string> GetRequestGet()
	{
		SortedDictionary<string, string> sortedDictionary = new SortedDictionary<string, string>();
		NameValueCollection queryString = base.Request.QueryString;
		string[] allKeys = queryString.AllKeys;
		for (int i = 0; i < allKeys.Length; i++)
		{
			sortedDictionary.Add(allKeys[i], base.Request.QueryString[allKeys[i]]);
		}
		return sortedDictionary;
	}
}
